<div class="container-fluid" style="margin: 0px 15px 0px 15px;">
	<ol class="breadcrumb">
	  <li><a href="<?php echo base_url('/index.php/inicio');?>">Início</a></li>
	  <li><a href="<?php echo base_url('index.php/eventos/consulta');?>">Audiência</a></li>
	  <li class="active">Info</li>
	</ol>
	<!-- Nav tabs -->
	<!--<ul class="nav nav-tabs" role="tablist">-->
	<ul class="nav nav-pills">
	  <li class="active"><a href="#info" role="tab" data-toggle="tab">Info</a></li>
	  <li><a href="#historico" role="tab" data-toggle="tab">Histórico</a></li>
	</ul>
	<hr></hr>
	<!-- Tab panes -->
	<div class="tab-content">
		<div class="tab-pane active" id="info">
			<br/>
			<form class ="form-horizontal" role="form" id="form" method="POST">
				<input type="hidden" value="<?php echo $audiencia->id;?>" name="id" id="id" >
				<input type="hidden" value="<?php echo $audiencia->processo_id;?>" name="idprocesso" id="idprocesso" >
				<input type="hidden" value="<?php echo $audiencia->tipoevento_id;?>" name="idevento" id="idevento" >
				<input type="hidden" value="<?php echo $audiencia->tipoevento_id;?>" name="idevento" id="idevento" >
				<div class="form-group">
					<label class="col-sm-2 control-label">Número Processo</label>
					<div class="col-sm-10">
					  <p class="form-control-static" style="color:blue;"><a href="<?php echo base_url('index.php/processos/info/'.$processo_id);?>" ><?php echo $numeroprocesso;?> </a></p>
					</div>
				</div>
				<div class="form-group">
				<label for="" class="col-sm-2 control-label">Tipo</label>
				<div class="col-sm-2">
					<?php 
						$class = 'class="form-control input-sm" readonly id="tipoevento"';
						echo form_dropdown('tipoevento', $tipoevento, $audiencia->tipoevento_id,$class);
					?>
				</div>
				</div>
				<div class="form-group">
				<label for="" class="col-sm-2 control-label">Local</label>
				<div class="col-sm-2">
				<?php 
					/*$data = array('name'=> 'local','id'=> 'local','value'=> $local,'placeholder'=> 'Local','class'=> 'form-control input-sm');
					echo form_input($data);*/
					
					$class = 'class="form-control input-sm" readonly id="local"';
					echo form_dropdown('local', $local, $nome_local,$class);
				?>
				</div>
				</div>
				
				<div class="form-group">
				<label for="" class="col-sm-2 control-label">Data</label>
				<div class="col-sm-2">
				<?php 
					//$data = array('readonly'=>'readonly','name'=> 'dia','id'=> 'dia','value'=> usaToBrHora($audiencia->dt_evento),'placeholder'=> 'Data','class'=> 'form-control input-sm');
					//echo form_input($data);
					
				?>
				<input type="text" name="dia" id="dia" value="<?php echo usaToBrHora($audiencia->dt_evento); ?>"  class="form-control input-sm" placeholder="Data" readonly>
				</div>
				</div>
				<!--<div class="form-group">
				<label for="" class="col-sm-2 control-label">Hora</label>
				<div class="col-sm-1">
				<?php 
					//$data = array('name'=> 'hora','id'=> 'hora','value'=> '','placeholder'=> 'Hora','class'=> 'form-control input-sm');
					//echo form_input($data);
				?>
				</div>
				</div> -->
				<div class="form-group">
				<label for="inputPassword3" class="col-sm-2 control-label">Observação</label>
				<div class="col-sm-4">
				<?php 
					$data = array('readonly'=>'readonly','name'=> 'observacao','id'=> 'observacao','placeholder'=> 'Observação','class'=> 'form-control input-sm','value'=>$audiencia->observacao,'rows'=>'3');
					echo form_textarea($data);
				?>
				</div>
				</div>
				<?php
				//PERMISSAO 
				if(viewPermissao(array('1','2'),$session_data)){
				?>
					<div class="form-group">
					<label for="" class="col-sm-2 control-label">Ação</label>
					<div class="col-sm-3">
					<?php 
						$status_evento = array('' =>'-- SELECIONE A OPÇÃO --','2'=>'REMARCAR','3'=>'CANCELAR','4'=>'CONCLUÍDO',);
						echo form_dropdown('status_evento',$status_evento,'','class="form-control input-sm" id="status_evento"');
					?>
					</div>
					</div>
					<div class="form-group">
					<div class="col-sm-offset-2 col-sm-10">
						<?php 
							$data = array('name'=>'salvar','type' => 'submit','class' => 'btn btn-primary','content' =>'Salvar');
							echo form_button($data);
						?>
						<a id="cancelar" href="<?php echo base_url('index.php/eventos/consulta');?>" class="btn btn-default"></span>Cancelar</a>
					</div>
					</div>
				<?php
				}
				?>
			</form>
			<div id="retorno"></div>
		</div>
		<div class="tab-pane" id="historico">
			<br/>
			<table id="example" class="display responsive nowrap" cellspacing="0" width="100%">
				<thead>
					<tr>
						<th>Data/Hora</th>
						<th>Autos/RT</th>
						<th>Autor(es)</th>
						<th>Réu(s)</th>
						<th>Tipo</th>
						<th>Adv. Responsável</th>
						<th>Status</th>
					</tr>
				</thead>
				<tbody>
					<?php
					foreach($evento as $p){
						echo "<tr>";
							echo "<td>".$p->dt_evento."</td>";
							echo "<td>".$p->numeroprocesso."</td>";
							echo "<td>".$p->autor."</td>";
							echo "<td>".$p->reu."</td>";
							echo "<td>".$p->nome_evento."</td>";
							echo "<td>".$p->nome_completo."</td>";
							echo "<td>";
							if($p->status_evento == '1'){
								echo ' <a href="#" class="btn btn-success btn-xs">ATIVO</a>';
							}elseif($p->status_evento == '2'){
								echo ' <a href="#" class="btn btn-warning btn-xs">REMARCADO</a>';
							}elseif($p->status_evento == '3'){
								echo ' <a href="#" class="btn btn-danger btn-xs">CANCELADO</a>';
							}elseif($p->status_evento == '4'){
								echo ' <a href="#" class="btn btn-info btn-xs">CONCLUÍDO</a>';
							}
							echo "</td>";
						echo "</tr>";
					}
					?>
				</tbody>
			</table>
		</div>
	</div>
	
</div>


<!-- FIM TRAMITE -->
	<script type="text/javascript" charset="utf-8">
		$(document).ready(function() {
			$('#dia').datetimepicker({dateFormat: "dd/mm/yy"});
			$("#form").validate({
				rules: {
					numero_processo: "required",
					status_evento: "required",
					dia: "required"
				},
				messages: {
					numero_processo: "Campo requerido",
					status_evento: "Campo requerido",
					dia: "Campo requerido"
				},
				submitHandler: function(form){
					var dados = $('#form').serialize();
					$.ajax({
						type: "POST",
						url: "<?php echo base_url('index.php/eventos/editar'); ?>",
						data: dados,
						success: function( data )
						{
							//alertify.success(data);
							if(data === 'OK'){
									$('#retorno').html('<div class="alert alert-success" role="alert">CADASTRO EFETUADO COM SUCESSO</div>');
									setTimeout(function() {
										$('#retorno').html('');
										window.location = "<?php echo base_url('index.php/eventos/consulta'); ?>";
									}, 2000);
								
								}else{
									$('#retorno').html(data);
								}
						},
						statusCode: {
							404: function() {
								alertify.error("Pagina nao encontrada");
							}
						}
					});
					return false;
				}
			});				
			$('#example').DataTable({
				"language": {
					"url": "<?php echo base_url('includes/js/Portuguese-Brasil.json'); ?>"
				},
				 "pagingType": "simple"
			});

			$('#status_evento').change( function(event){
				if($('#status_evento').val() == '2'){
						$("#dia").removeAttr('readonly','false');
						$("#local").removeAttr('readonly','false');
						$("#tipoevento").removeAttr('readonly','false');
						$("#observacao").removeAttr('readonly','false');
				}else{
						$("#dia").attr('readonly','readonly');
						$("#local").attr('readonly','readonly');
						$("#tipoevento").attr('readonly','readonly');
						$("#observacao").attr('readonly','readonly');
				}
			});
					
			
			
		});
	</script>
</body>
</html>